﻿using System;
using System.Collections;
using MoreEPG.Helper;

namespace MoreEPG.Model
{
    

    /// <summary>
    /// A Class to represent a particular instance of a TV Programming airing
    /// </summary>
    public class TVProgramme
    {
        /// <summary>
        /// Time that the show starts.  In UTC Time.
        /// </summary>
        public DateTime startTime { get; set; }

        /// <summary>
        /// Time that the show ends.  In UTC Time.
        /// </summary>
        public DateTime stopTime { get; set; }

        /// <summary>
        /// The channel 
        /// </summary>
        public string channel { get; set; }

        /// <summary>
        /// The description
        /// </summary>
        public string description { get; set; }

        /// <summary>
        /// The shortDescription
        /// </summary>
        public string shortDescription { get; set; }

        
        /// <summary>
        /// MPAA Rating.
        /// </summary>
        public mpaaRating rating { get; set; }

        /// <summary>
        /// halfStars.
        /// </summary>
        public string halfStars { get; set; }

        /// <summary>
        /// episodeTitle.
        /// </summary>
        public string episodeTitle { get; set; }
                
        /// <summary>
        /// keywords (comma-delimited)
        /// </summary>
        public string keywords { get; set; }

        /// <summary>
        /// Title of the program.
        /// </summary>
        public string title { get; set; }

        /// <summary>
        /// An id for the program that is unique within an MXF file
        /// </summary>
        public int id { get; set; }

        /// <summary>
        /// Whether the program is part of a series or not.
        /// We usually set this to true by default, but we should be more clever about it by checking reccurrance etc.
        /// </summary>
        public bool isSeries { get; set; }

        /// <summary>
        /// Whether the program is HDTV or not
        /// </summary>
        public bool isHDTV { get; set; }

        /// <summary>
        /// unique ID for program in the MXF database.  usually a generated guid
        /// </summary>
        public string uid { get; set; }

        /// <summary>
        /// Image to be schown in guide for the programm
        /// </summary>
        public string guideImageID { get; set; }

        /// <summary>
        /// ID List of Actors belong to this Programme
        /// </summary>
        public ArrayList ActorRoles { get; set; }

        /// <summary>
        /// ID List of Writers belong to this Programme
        /// </summary>
        public ArrayList WriterRoles { get; set; }

        /// <summary>
        /// ID List of GuestActors belong to this Programme
        /// </summary>
        public ArrayList GuestActorRoles { get; set; }

        /// <summary>
        /// ID List of Hosts belong to this Programme
        /// </summary>
        public ArrayList HostRoles { get; set; }

        /// <summary>
        /// ID List of Producers belong to this Programme
        /// </summary>
        public ArrayList ProducerRoles { get; set; }

        /// <summary>
        /// ID List of Directors belong to this Programme
        /// </summary>
        public ArrayList DirectorRoles { get; set; }

        /// <summary>
        /// Audio Format of the Programme
        /// </summary>
        public audioFormats audioFormat { get; set; }

        /// <summary>
        /// Indicates if the programme is a movie
        /// </summary>
        public bool isMovie { get; set; }

        /// <summary>
        /// Indicates if the programme is a Special
        /// </summary>
        public bool isSpecial { get; set; }

        /// <summary>
        /// Indicates if the programme is Sport
        /// </summary>
        public bool isSports { get; set; }

        /// <summary>
        /// Indicates if the programme is News
        /// </summary>
        public bool isNews { get; set; }

        /// <summary>
        /// Indicates if the programme is a Kid
        /// </summary>
        public bool isKids { get; set; }

        /// <summary>
        /// Indicates if the programme is Live
        /// </summary>
        public bool isLive { get; set; }

        /// <summary>
        /// Indicates if the programme is Live and Sport
        /// </summary>
        public bool isLiveSports { get; set; }

        /// <summary>
        /// Indicates if the Programme is a repeat
        /// </summary>
        public bool isRepeat { get; set; }

        /// <summary>
        /// if it is a repeat, it is filled with Original Airdate
        /// </summary>
        public DateTime originalAirdate { get; set; }

        /// <summary>
        /// Main constructor for class
        /// </summary>
        /// <param name="theID">The ID to use for the program.  Needs to be unique to with an MXF file.</param>
        /// <param name="GUID">The guid that will be loaded into the MXF.</param>
        public TVProgramme(int theID, string GUID)
        {
            id = theID;
            isSeries = true;
            uid = "!Program!" + GUID;
        }

        public void setUID(string GUID)
        {
            uid = "!Program!" + GUID;
        }

        /// <summary>
        /// Get the length of the program in seconds.
        /// </summary>
        /// <returns>String:  The program length in seconds</returns>
        public string duration()
        {
            return stopTime.Subtract(startTime).TotalSeconds.ToString();
        }

        /// <summary>
        /// Get a string representation of the program
        /// </summary>
        /// <returns>A string representation</returns>
        public override string ToString()
        {
            return title + " : " + description + ",@ " + startTime.ToString() + ",  for " + duration() + ", on " + channel + ", " + rating;
        }

        /// <summary>
        /// Get a short string representation of the program
        /// </summary>
        /// <returns>A short string representation</returns>
        public string ToShortString()
        {
            return id.ToString() + " : " + uid + ":" + title;
        }

        /// <summary>
        /// Make a copy of Object
        /// </summary>
        /// <param name="Prog"></param>
        /// <returns></returns>
        public static TVProgramme Copy(TVProgramme Prog)
        {
            return (TVProgramme)Prog.MemberwiseClone();
        }
    }
}
